package cn.com.spic.demo.impl;

import cn.com.spic.demo.api.ContractQueryService;
import cn.com.spic.demo.dto.ContractDTO;
import cn.com.spic.demo.dto.ContractSearchVO;
//import cn.com.spic.demo.po.ContractPO;
//import cn.com.spic.demo.service.ContractService;
//import com.yonyou.iuap.baseservice.vo.GenericAssoVo;
//import com.yonyou.iuap.ucf.dao.support.EntitySqlParam;
//import com.yonyou.iuap.ucf.dao.support.UcfPageRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.io.Serializable;

@Service
@RequiredArgsConstructor
public class ContractQueryServiceImpl implements ContractQueryService {
    @Override
    public ContractDTO save(ContractDTO contract) {
        return null;
    }

    @Override
    public ContractSearchVO getById(Serializable id) {
        return null;
    }

    @Override
    public int deleteById(String id) {
        return 0;
    }

    @Override
    public Page<ContractSearchVO> page(Pageable pageable) {
        return null;
    }

//    private final ContractService contractService;

    // 通过Id获取详情
//    @Override
//    public ContractSearchVO getById(Serializable id) {
////        GenericAssoVo<ContractPO> contractPO = contractService.getAssoVo(id);
//        ContractSearchVO contractSearchVO = new ContractSearchVO();
//        contractSearchVO.setCreateUser(contractPO.getEntity().getCreateUser());
//        contractSearchVO.setId(contractPO.getEntity().getId());
//        BeanUtils.copyProperties(contractSearchVO, contractPO.getEntity());
//        return contractSearchVO;
//    }
//
//    @Override
//    public Page<ContractSearchVO> page(Pageable pageable) {
//        Page<ContractPO> contractPOS = contractService.selectAllByPage(UcfPageRequest.of(pageable.getPageNumber(), pageable
//                .getPageSize(), pageable.getSort()), new EntitySqlParam(ContractPO.class));
//        return contractPOS.map(contractPO -> {
//            ContractSearchVO contractSearchVO = new ContractSearchVO();
//            contractSearchVO.setId(contractPO.getId());
//            BeanUtils.copyProperties(contractPO, contractSearchVO);
//            return contractSearchVO;
//        });
//    }
//
//    @Override
//    public int deleteById(String id) {
//        return contractService.delete(id);
//    }
//
//    @Override
//    public ContractDTO save(ContractDTO contract) {
//        ContractPO contractPO = new ContractPO();
//        BeanUtils.copyProperties(contract, contractPO);
//        contractPO.setId(contract.getId());
//        contractService.save(contractPO);
//        BeanUtils.copyProperties(contractPO, contract);
//        return contract;
//    }

}
